package com.pdsu.xpf.graduation01.service.impl;

import com.pdsu.xpf.graduation01.dao.IOrderDao;
import com.pdsu.xpf.graduation01.dto.OrderDTO;
import com.pdsu.xpf.graduation01.service.IOrderService;
import com.pdsu.xpf.graduation01.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class OrderServiceImpl implements IOrderService {

    final
    IOrderDao iOrderDao;

    public OrderServiceImpl(IOrderDao iOrderDao) {
        this.iOrderDao = iOrderDao;
    }

    @Override
    public Integer createOrder(int uid, int cid, String cname, int ucnumber, String image, String orderNumberByTime) {
        SimpleDateFormat sm= new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String date = sm.format(new Date());
        return iOrderDao.createOrder(uid, cid, cname, ucnumber, image, orderNumberByTime,date);
    }

    @Override
    public List<OrderDTO> getOrderDTOListByOrderUID(int uid) {
        return iOrderDao.getOrderDTOListByOrderUID(uid);
    }

    @Override
    public List<OrderVO> findAllOrderVO() {
        return iOrderDao.findAllOrderVO();
    }

    @Override
    public int delOrderByOID(int oid) {
        return iOrderDao.delOrderByOID(oid);
    }

    @Override
    public List<OrderVO> searchOrderByKey(String key) {
        return iOrderDao.searchOrderByKey(key);
    }

    @Override
    public Integer updateOrderStateByOrderNumber(String order_number) {
        return iOrderDao.updateOrderStateByOrderNumber(order_number);
    }


}
